package com.xbts.screen.controller.workshop;

import com.xbts.common.core.constant.CacheConstants;
import com.xbts.common.core.constant.Constants;
import com.xbts.common.core.utils.StringUtils;
import com.xbts.common.core.web.controller.BaseController;
import com.xbts.common.core.web.domain.AjaxResult;
import com.xbts.common.core.web.domain.BaseHistogramResult;
import com.xbts.common.core.web.domain.BasePieChartResult;
import com.xbts.common.security.annotation.RequiresPermissions;
import com.xbts.screen.domain.workshop.vo.*;
import com.xbts.screen.service.ILineService;
import com.xbts.screen.service.IWeVirtualDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 线路车间Controller
 */
@Api(tags = "线路车间")
@RestController
@RequestMapping("/line")
public class LineController extends BaseController {


    @Autowired
    private ILineService lineService;

    /**
     * 实时达成率1
     */
    @ApiOperation("实时达成率")
    @RequiresPermissions("workshop:line:realTimeAchievementRate")
    @GetMapping("/realTimeAchievementRate")
    public AjaxResult realTimeAchievementRate(){
        RealTimeAchievementRateVO vo = lineService.realTimeAchievementRate();
        return success(vo);
    }
    /**
     * 近10天达成率1
     */
    @ApiOperation("近10天达成率")
    @RequiresPermissions("workshop:line:tenDaysAchievementRate")
    @GetMapping("/tenDaysAchievementRate")
    public AjaxResult tenDaysAchievementRate(){
        BaseHistogramResult result = lineService.tenDaysAchievementRate();
        return success(result);
    }
    /**
     * 达成率根据时间分组1
     */
    @ApiOperation("达成率根据时间分组")
    @RequiresPermissions("workshop:line:achievementRateGroupByTimeType")
    @GetMapping("/achievementRateGroupByTimeType")
    public AjaxResult achievementRateGroupByTimeType(){
        StatisticalRateGroupByTimeVO vo = lineService.achievementRateGroupByTimeType();
        return success(vo);
    }
    /**
     * 水单耗
     */
    @ApiOperation("水单耗")
    @RequiresPermissions("workshop:line:waterUnitConsume")
    @GetMapping("/waterUnitConsume")
    public AjaxResult waterUnitConsume(){
        BaseHistogramResult result = lineService.waterUnitConsume();
        return success(result);
    }
    /**
     * 电单耗
     */
    @ApiOperation("电单耗")
    @RequiresPermissions("workshop:line:electricityUnitConsume")
    @GetMapping("/electricityUnitConsume")
    public AjaxResult electricityUnitConsume(){
        BaseHistogramResult result = lineService.electricityUnitConsume();
        return success(result);
    }
    /**
     * 排产计划1
     */
    @ApiOperation("排产计划")
    @RequiresPermissions("workshop:line:productionSchedule")
    @GetMapping("/productionSchedule")
    public AjaxResult productionSchedule(){
        List<ProductionScheduleVO> vos = lineService.productionSchedule();
        return success(vos);
    }
    /**
     * 周转率
     */
    @ApiOperation("周转率")
    @RequiresPermissions("workshop:line:turnoverRate")
    @GetMapping("/turnoverRate")
    public AjaxResult turnoverRate(){
        BaseHistogramResult vo = lineService.turnoverRate();
        return success(vo);
    }
    /**
     * 周转率根据时间类型分组
     */
    @ApiOperation("周转率根据时间类型分组")
    @RequiresPermissions("workshop:line:turnoverRateGroupByTimeType")
    @GetMapping("/turnoverRateGroupByTimeType")
    public AjaxResult turnoverRateGroupByTimeType(){
        StatisticalRateGroupByTimeVO vo = lineService.turnoverRateGroupByTimeType();
        return success(vo);
    }
    /**
     * 线路曝光合格率1
     */
    @ApiOperation("线路曝光合格率")
    @RequiresPermissions("workshop:line:lineExposurePassRate")
    @GetMapping("/lineExposurePassRate")
    public AjaxResult lineExposurePassRate(){
        PassRateVO vo = lineService.lineExposurePassRate();
        return success(vo);
    }
    /**
     * 线路曝光不良统计1
     */
    @ApiOperation("线路曝光不良统计")
    @RequiresPermissions("workshop:line:lineExposureBadStatistics")
    @GetMapping("/lineExposureBadStatistics")
    public AjaxResult samplingBadStatistics(){
        List<BasePieChartResult> resultList = lineService.lineExposureBadStatistics();
        return success(resultList);
    }
    /**
     * 蚀刻首件合格率1
     */
    @ApiOperation("蚀刻首件合格率")
    @RequiresPermissions("workshop:line:etchingFirstArticlePassRate")
    @GetMapping("/etchingFirstArticlePassRate")
    public AjaxResult etchingFirstArticlePassRate(){
        PassRateVO vo = lineService.etchingFirstArticlePassRate();
        return success(vo);
    }
    /**
     * 蚀刻首件不良统计1
     */
    @ApiOperation("蚀刻首件不良统计")
    @RequiresPermissions("workshop:line:etchingFirstArticleBadStatistics")
    @GetMapping("/etchingFirstArticleBadStatistics")
    public AjaxResult etchingFirstArticleBadStatistics(){
        List<BasePieChartResult> resultList = lineService.etchingFirstArticleBadStatistics();
        return success(resultList);
    }
    /**
     * 线路曝光合格率趋势
     */
    @ApiOperation("线路曝光合格率趋势")
    @RequiresPermissions("workshop:line:lineExposurePassRateTrend")
    @GetMapping("/lineExposurePassRateTrend")
    public AjaxResult lineExposurePassRateTrend(){
        BaseHistogramResult result = lineService.lineExposurePassRateTrend();
        return success(result);
    }
    /**
     * 蚀刻首件合格率趋势
     */
    @ApiOperation("蚀刻首件合格率趋势")
    @RequiresPermissions("workshop:line:etchingFirstArticlePassRateTrend")
    @GetMapping("/etchingFirstArticlePassRateTrend")
    public AjaxResult etchingFirstArticlePassRateTrend(){
        BaseHistogramResult result = lineService.etchingFirstArticlePassRateTrend();
        return success(result);
    }

    /**
     * 料号批次合格率记录1
     */
    @ApiOperation("料号批次合格率记录")
    @RequiresPermissions("workshop:line:passRateRecord")
    @GetMapping("/passRateRecord")
    public AjaxResult passRateRecord(){
        List<PassRateRecordVO> resultList = lineService.passRateRecord();
        return success(resultList);
    }
}
